package com.iss.okair.service.baseinfo;

import com.iss.common.MD5Tools;
import com.iss.okair.db.entity.Sysuser;
import com.iss.okair.db.entity.SysuserRole;
import com.iss.okair.db.mapper.SysuserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysuserService {

    @Resource
    private SysuserMapper mapper;

    public Sysuser login(Sysuser loginUser){
        loginUser.setPwd(MD5Tools.buildMD5String(loginUser.getPwd()));
        List<Sysuser> result=mapper.loginCheck(loginUser);
        return result.size()==1?result.get(0):null;
    }

    public List<SysuserRole> roleList(){
        return mapper.selectAllRoler();
    }
    public List<Sysuser> findByExample(Sysuser example){
        return mapper.selectByExample(example);
    }
}
